<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" type="text/css" href="css/sellerUpdate.css"/>
		<script src="js/jquery-2.1.0.js"></script>
		<script>
			$(function(){

				$.ajax("/fengwei/express/ShowSellerUpdate",{
					type:"get",
					data:{},
					success:function(data){

						var dataObj = eval('('+data+')');
						console.log(dataObj);
						setData(dataObj);

					},
					error:function(){
						console.log(0);
					}
				});

				function setData(dataObj){

					var content = document.getElementById('orderList');
					for(var i = 0;i<dataObj.length;i++){

						var arr = dataObj[i].fileUrl.split("\\");
						var src = arr[arr.length-2]+"/"+arr[arr.length-1];
						var goodsName = dataObj[i].goodsName;
						var goodsCity = dataObj[i].goodsCity;
						var goodsPrice = dataObj[i].goodsPrice;
						var goodsUnit = dataObj[i].goodsUnit;
						var goodsorderStatus = dataObj[i].goodsorderStatus;

						var newDiv = document.createElement("div");
						content.appendChild(newDiv);

						newDiv.innerHTML = "<div id='update_goods'>"+
						        "<img class='update_goods_img' src="+src+"/>"+
								"<div class='update_goods_msg'>名称：<span class='goods_name'>"+goodsName+"</span> <br />"+
								"产地：<span class='goods_place'>"+goodsCity+"</span> <br />"+
								"价格：<span class='goods_price'>￥"+goodsPrice+""+goodsUnit+"</span>"+
								"</div> </div>"+
								"<span class='state_txt'>"+
								"+修改订单状态：</span>"+
						        "<select name='state' id='state"+i+"' class='status' >"+
								"<option  value='1'>未发货</option>"+
								"<option value='2'>运送中</option>"+
								"<option value='3'>交易完成</option>"+
								"</select>";


						if(goodsorderStatus == 1){
							$("#state"+i+" option[value='1']").attr("selected", true);
						} else if(goodsorderStatus == 2){
							$("#state"+i+" option[value='2']").attr("selected", true);
						} else if(goodsorderStatus == 3){
							$("#state"+i+" option[value='3']").attr("selected", true);
						}

						var status = document.getElementsByClassName('status');
						status[i].index = i;
						status[i].onchange = function(){
							var count = this.index;
							var index = this.selectedIndex; // 选中索引
							var goodsorderStatus = this.options[index].value; // 选中值
					console.log(index+","+goodsorderStatus);
							$.ajax("/fengwei/express/sellerUpdate",{
								type:"post",
								data:{
									'goodsorderId':dataObj[count].goodsorderId,
									'goodsorderStatus':goodsorderStatus
								},
								success:function(data){

									console.log(data);

								},
								error:function(){
									console.log(0);
								}
							});
						}

					}
				}


			})
		</script>
	</head>
	<body>
		
		<div id="head">
			<a href=”#” onClick="javascript :history.back(-1);"> <img class="img_return" src="img/return.png"/> </a>
			<span class="head_txt">订单更新</span>
		</div>     <!--end -->
		
		<div id="orderList">
			<!--<div>-->
			<!--<div id="update_goods">-->
					<!--<img class="update_goods_img" src="img/03.jpg"/>-->
					<!--<div class="update_goods_msg">名称：<span class="goods_name">大闸蟹蟹</span> <br />-->
								  	      <!--产地：<span class="goods_place">成都</span> <br />-->
								  	      <!--价格：<span class="goods_price">￥50/kg</span>-->
					<!--</div>-->
			<!--</div>-->
				<!-- -->
				<!--<span class="state_txt">-->
		 				<!--修改订单状态：	-->
		 		<!--</span>-->
				<!--<select name="state" id="state" >-->
					<!--<option  value="1" selected="selected">未发货</option>-->
					<!--<option value="2">运送中</option>-->
					<!--<option value="3">交易完成</option>-->
				<!--</select>-->
				<!--</div>-->
				
		</div>    <!--end -->
		
	</body>
</html>
